<cfsetting enablecfoutputonly="true" />
<!--- @@displayname: List FLV files as teasers --->
<!--- @@author: Jeff Coughlin (jeff[at]jeffcoughlin[dot]com) --->
<!--- @@hashURL: true --->

<!--- import tag libraries --->
<cfimport taglib="/farcry/core/tags/formtools/" prefix="ft" />
<cfimport taglib="/farcry/core/tags/webskin" prefix="skin" />

<cfscript>
  // Declare local variables
  lastGroupName = "default_empty";
  loopCount = 0;
  columnNumber = 0;
  stParam = structNew();
    
  //Filter By Category
  lCategoryIds = arrayToList(stObj.aFlvFileCategories);
  
  // create objects
  oJcFarcryFlvFile = application.stplugins.jcfarcryflvplayer.oJcFarcryFlvFile;
  qFlvFiles = oJcFarcryFlvFile.getLibraryDataFlvFiles(
      bActive = true,
      bJoinCategories = true,
      lCategoryIds = lCategoryIds,
      orderBy = 'catTitle, label'
      );
</cfscript>

<!--- don't allow column counts to be less than 1 --->
<cfif stObj.numberOfColumns lt 1>
  <cfset stObj.numberOfColumns = 1 />
</cfif>

<cfif stObj.numberOfColumns gt 1>
  <cfset default.liStyle_extra = "width: #int(100/stObj.numberOfColumns)-1#%;" />
<cfelse>
  <cfset default.liStyle_extra = "width: 98%;" />
</cfif>

<!---
<!--- Just one column --->
<cfset loopCount = 0 />
<cfloop query="qFlvFiles">
  <cfset loopCount = loopCount +1 />
  <cfif lastGroupName neq qFlvFiles.catTitle or loopCount eq 1>
    <cfif loopCount neq 1>
      <cfoutput></ul>#chr(10)##chr(13)#</cfoutput>
    </cfif>
    <cfset lastGroupName = qFlvFiles.catTitle />
    <cfoutput>#chr(10)##chr(13)#<h2 class="jcFarcryFlvHeading">#qFlvFiles.catTitle#</h2>#chr(10)##chr(13)#</cfoutput>
    <cfoutput><ul class="jcFarcryFlvTeaserList">#chr(10)##chr(13)#</cfoutput>
  </cfif>
  <skin:view typename="jcFarcryflvfile" objectid="#qFlvFiles.objectId#" webskin="displayTeaserStandard" />
  <cfif loopCount eq qFlvFiles.recordCount>
    <cfoutput></ul>#chr(10)##chr(13)#</cfoutput>
  </cfif>
</cfloop>
--->



<cfloop query="qFlvFiles">
  <!--- Set loop info variables --->
  <cfset loopCount = loopCount +1 />
  <cfset columnNumber = columnNumber + 1 />
  <cfset stParam.liStyle_extra = default.liStyle_extra />
  
  <!--- Reset columnNumber info if needed --->
  <cfif columnNumber gt stObj.numberOfColumns>
    <cfset columnNumber = 1 />
    <cfset stParam.liClass_extra = "" />
  <cfelse>
    <cfset stParam.liClass_extra = " sideBySide" />
  </cfif>
  
  <!--- Start new unordered list if required --->
  <cfif lastGroupName neq qFlvFiles.catTitle or loopCount eq 1>
    <cfif loopCount neq 1>
      <cfoutput></ul>#chr(10)##chr(13)#</cfoutput>
    </cfif>
    
    <!--- Reset columnNumber info --->
    <cfset columnNumber = 1 />
    <cfset stParam.liClass_extra = "" />   

    <cfset lastGroupName = qFlvFiles.catTitle />
    <cfif qFlvFiles.catTitle neq "">
      <cfoutput>#chr(10)##chr(13)#<h2 class="jcFarcryFlvHeading">#qFlvFiles.catTitle#</h2>#chr(10)##chr(13)#</cfoutput>
    </cfif>
    <cfoutput><ul class="jcFarcryFlvTeaserList">#chr(10)##chr(13)#</cfoutput>
  </cfif>

  <!--- Output view based on column number --->
  <skin:view typename="jcFarcryflvfile" objectid="#qFlvFiles.objectId#" webskin="displayTeaserStandard" stParam="#stParam#" />

  <!--- End unordered list if required --->
  <cfif loopCount eq qFlvFiles.recordCount>
    <cfoutput></ul>#chr(10)##chr(13)#</cfoutput>
  </cfif>

</cfloop>

<cfsetting enablecfoutputonly="false" />